<template>
  <div class="updata">
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">商品名:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="name"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">商品价格:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="price"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">商品库存:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="goodsNum"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">生产日期:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="production"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">保质期:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="shelfLife"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">产地:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="producer"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">商品重量:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="weight"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">商品描述:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="desc"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">是否打折:</p>
      <el-radio v-model="radio" label="1">打折</el-radio>
      <el-radio v-model="radio" label="2">不打折</el-radio>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">商品大种类:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="type"
        clearable
      >
      </el-input>
    </div>
    <div style="display: flex; width: 500px; align-items: center">
      <p style="width: 100px">商品小种类:</p>
      <el-input
        style="width: 300px"
        placeholder="请输入内容"
        v-model="kind"
        clearable
      >
      </el-input>
    </div>
    <div>
     
    </div>
    <p style="margin-left: 200ox">
      <el-button @click="upClick" type="primary">修改</el-button>
    </p>
  </div>
</template>
<script>
import goodsApi from "../../api/shopGoods";
export default {
  props: {
    isUpdata: {
      type: Boolean,
      default: false,
    },
    update: {
      type: Object,
      default: () => {},
    },
  },
  mounted() {

    console.log(this.update.images);
  },
  data() {
    return {
      isAleart:false,
      name: this.update.name,
      price: this.update.price,
      goodsNum: this.update.goodsNum,
      production: this.update.production,
      shelfLife: this.update.shelfLife,
      producer: this.update.producer,
      weight: this.update.weight,
      desc: this.update.desc,
      type: this.update.type,
      kind: this.update.kind,
      discount: false,
      radio: "1",
      images:this.update.images
    };
  },
  methods: {
    async upClick() {
      const goods = {
        _id: this.update._id,
        name: this.$data.name,
        price: this.$data.price,
        goodsNum: this.$data.goodsNum,
        production: this.$data.production,
        shelfLife: this.$data.shelfLife,
        producer: this.$data.producer,
        weight: this.$data.weight,
        desc: this.$data.desc,
        type: this.$data.type,
        kind: this.$data.kind,
        discount: this.$data.radio === "1" ? true : false,
      };
      await goodsApi.updataGoods(goods);
     
      this.$emit("closepop");
    },
  },
};
</script>

<style scoped>
</style>
